<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of welcome
 *
 * @author Obi
 */
class News extends MY_Controller {

    function __construct() {
        parent::__construct();
        $this->mnews = new M_news();
    }

    function index() {

        $this->news();
    }
	
	function news() {
		
		$this->load->library('pagination');
        $config['base_url'] = base_url() . 'main/news/news';
        $config['total_rows'] = $this->mnews->where("status = 1")->count();
        $config['per_page'] = 10;
        $config['uri_segment'] = 4;
        $config['full_tag_open'] = '<p class="paging">';
        $config['full_tag_close'] = '</p>';
        $this->pagination->initialize($config);
        $data['link_pagging'] = $this->pagination->create_links();
        $hal = $this->uri->segment(4, 0);

        $data['search'] = "";

        $data['menu'] = array(
//            $this->load->view('parsing/client/menu_right_search', '', true),
            $this->load->view('parsing/client/menu_right_katagori', '', true),
            $this->load->view('parsing/client/menu_right_db', '', true),
        );

		$data['title'] = "News";
        $data['list_data'] = $this->mnews->where("status = 1")->order_by("datekeyin", "desc")->limit(10, $hal)->get();
        $data['isi'] = 'news';

        $this->load->view('template_client', $data);
    }
	
	function detail($id = NULL) {
        $data['menu'] = array(
//            $this->load->view('parsing/client/menu_right_search', '', true),
            $this->load->view('parsing/client/menu_right_katagori', '', true),
            $this->load->view('parsing/client/menu_right_db', '', true),
        );

        $data['title'] = "News";
        $data['isi'] = 'news_detail';
		$data['news_detail'] = $this->mnews->where("newsid = '$id'")->get();
		$data['test'] = $id;

        $this->load->view('template_client', $data);
    }
	
    function simpan() {

        $data = array(
            'nama_pengirim' => $this->input->post('nama_pengirim'),
            'email' => $this->input->post('email'),
            'telp' => $this->input->post('telp'),
            'pesan' => $this->input->post('pesan'),
            'tanggal' => date('Y-m-d H:i:s')
        );

        $this->mkontak->insert($data);


        $data['menu'] = array(
            $this->load->view('parsing/client/menu_right_search', '', true),
            $this->load->view('parsing/client/menu_right_katagori', '', true),
            $this->load->view('parsing/client/menu_right_db', '', true),
        );

        $data['title'] = "Kontak Kami";
        $data['isi'] = 'isi_kontak';

        $this->load->view('template_client', $data);

        redirect("main/kontak/kontak_save/13");
    }

    function kontak_save($alert = NULL) {
        $data['menu'] = array(
            $this->load->view('parsing/client/menu_right_katagori', '', true),
            $this->load->view('parsing/client/menu_right_db', '', true),
        );

        $data['title'] = "Kontak Kami";
        $data['isi'] = 'isi_kontak';
        $data['alert'] = $alert;

        $this->load->view('template_client', $data);
    }

}

?>
